package com.itheima.tliasmanager.controller;

import com.itheima.tliasmanager.pojo.domain.Clazz;
import com.itheima.tliasmanager.pojo.dto.ClazzQueryParam;
import com.itheima.tliasmanager.pojo.vo.PageResult;
import com.itheima.tliasmanager.pojo.vo.Result;
import com.itheima.tliasmanager.service.ClazzService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping("/clazzs")
@RestController  //@Component
public class ClazzController {

    @Autowired
    private ClazzService clazzService;

    @GetMapping
    public Result page(ClazzQueryParam queryParam){
        //1.接收请求参数：kv格式
        //请求参数数量较多的：推荐定义实体对象接收
        log.info("分页查询员工列表，参数：{}",queryParam);

        //2.调用service业务方法，获取员工列表
        PageResult<Clazz> pageResult = clazzService.page(queryParam);

        //3.封装并返回结果数据
        return Result.success(pageResult); //code=1,msg='success',data=pageResult(total/rows)
    }

}
